package com.lingkang.flychat.config;

import com.lingkang.flychat.ws.NettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class NettyConfig implements ApplicationRunner {

    @Autowired
    private NettyServer nettyServer;

    private int nettyPort=8081;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    nettyServer.NettyServer(nettyPort);
                } catch (Exception e) {
                    System.out.println("Netty启动失败！");
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
